package com.easyban.controller;

import com.easyban.common.R;
import com.easyban.dto.ParentCategoriesDto;
import com.easyban.entity.ParentCategories;
import com.easyban.service.ParentCategoriesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/parentCategories")
@Slf4j
public class ParentCategoriesController {
    @Autowired
    private ParentCategoriesService parentCategoriesService;

    @GetMapping
    public R<List<ParentCategories>> getAllParentCategories() {
        List<ParentCategories> list = parentCategoriesService.list();
        return R.success(list);
    }

/*    @GetMapping("/{PId}")
    public R<String> getParentCategoriesById(@PathVariable int PId) {
        ParentCategories parentCategories = parentCategoriesService.getById(PId);
        return R.success(parentCategories.getName());
    }*/

    @GetMapping("/list")
    public R<List<ParentCategoriesDto>> getParentCategoryList() {
        List<ParentCategoriesDto> list = parentCategoriesService.allList();
        return R.success(list);
    }
}
